﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Text;

namespace SimpleCRUDDemo.Core
{
    public class DBConfiguration
    {
        public static IConfiguration GetConfiguration()
        {
            var builder = new ConfigurationBuilder()
               .SetBasePath(AppContext.BaseDirectory)
               .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
               .AddEnvironmentVariables();
            return builder.Build();
        }

        public static DbOption GetDbOption() {
            var result = GetConfiguration().GetSection("DbOption");

            return result.Get<DbOption>(); ;
        }
    }
}
